\(\int \frac {\cot (x)}{b \cos (x)+a \sin (x)} \, dx\) [294]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 14, antiderivative size = 48 \[ \int \frac {\cot (x)}{b \cos (x)+a \sin (x)} \, dx=-\frac {\text {arctanh}(\cos (x))}{b}+\frac {a \text {arctanh}\left (\frac {a \cos (x)-b \sin (x)}{\sqrt {a^2+b^2}}\right )}{b \sqrt {a^2+b^2}} \]

[Out]

-arctanh(cos(x))/b+a*arctanh((a*cos(x)-b*sin(x))/(a^2+b^2)^(1/2))/b/(a^2+b^2)^(1/2)

Rubi [A] (verified)

Time = 0.09 (sec) , antiderivative size = 48, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 4, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.286, Rules used = {3189, 3855, 3153, 212} \[ \int \frac {\cot (x)}{b \cos (x)+a \sin (x)} \, dx=\frac {a \text {arctanh}\left (\frac {a \cos (x)-b \sin (x)}{\sqrt {a^2+b^2}}\right )}{b \sqrt {a^2+b^2}}-\frac {\text {arctanh}(\cos (x))}{b} \]

[In]

Int[Cot[x]/(b*Cos[x] + a*Sin[x]),x]

[Out]

-(ArcTanh[Cos[x]]/b) + (a*ArcTanh[(a*Cos[x] - b*Sin[x])/Sqrt[a^2 + b^2]])/(b*Sqrt[a^2 + b^2])

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 3153

Int[(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> Dist[-d^(-1), Subst[Int
[1/(a^2 + b^2 - x^2), x], x, b*Cos[c + d*x] - a*Sin[c + d*x]], x] /; FreeQ[{a, b, c, d}, x] && NeQ[a^2 + b^2,
0]

Rule 3189

Int[(cos[(c_.) + (d_.)*(x_)]^(m_.)*sin[(c_.) + (d_.)*(x_)]^(n_.))/(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(
c_.) + (d_.)*(x_)]), x_Symbol] :> Int[ExpandTrig[cos[c + d*x]^m*(sin[c + d*x]^n/(a*cos[c + d*x] + b*sin[c + d*
x])), x], x] /; FreeQ[{a, b, c, d, m, n}, x] && IntegersQ[m, n]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rubi steps \begin{align*} \text {integral}& = \int \left (\frac {\csc (x)}{b}-\frac {a}{b (b \cos (x)+a \sin (x))}\right ) \, dx \\ & = \frac {\int \csc (x) \, dx}{b}-\frac {a \int \frac {1}{b \cos (x)+a \sin (x)} \, dx}{b} \\ & = -\frac {\text {arctanh}(\cos (x))}{b}+\frac {a \text {Subst}\left (\int \frac {1}{a^2+b^2-x^2} \, dx,x,a \cos (x)-b \sin (x)\right )}{b} \\ & = -\frac {\text {arctanh}(\cos (x))}{b}+\frac {a \text {arctanh}\left (\frac {a \cos (x)-b \sin (x)}{\sqrt {a^2+b^2}}\right )}{b \sqrt {a^2+b^2}} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.14 (sec) , antiderivative size = 60, normalized size of antiderivative = 1.25 \[ \int \frac {\cot (x)}{b \cos (x)+a \sin (x)} \, dx=\frac {-\frac {2 a \text {arctanh}\left (\frac {-a+b \tan \left (\frac {x}{2}\right )}{\sqrt {a^2+b^2}}\right )}{\sqrt {a^2+b^2}}-\log \left (\cos \left (\frac {x}{2}\right )\right )+\log \left (\sin \left (\frac {x}{2}\right )\right )}{b} \]

[In]

Integrate[Cot[x]/(b*Cos[x] + a*Sin[x]),x]

[Out]

((-2*a*ArcTanh[(-a + b*Tan[x/2])/Sqrt[a^2 + b^2]])/Sqrt[a^2 + b^2] - Log[Cos[x/2]] + Log[Sin[x/2]])/b

Maple [A] (verified)

Time = 0.52 (sec) , antiderivative size = 49, normalized size of antiderivative = 1.02

method result size
default \(\frac {\ln \left (\tan \left (\frac {x}{2}\right )\right )}{b}+\frac {2 a \,\operatorname {arctanh}\left (\frac {-2 b \tan \left (\frac {x}{2}\right )+2 a}{2 \sqrt {a^{2}+b^{2}}}\right )}{b \sqrt {a^{2}+b^{2}}}\) \(49\)
risch \(-\frac {i a \ln \left ({\mathrm e}^{i x}-\frac {i a +b}{\sqrt {-a^{2}-b^{2}}}\right )}{\sqrt {-a^{2}-b^{2}}\, b}+\frac {i a \ln \left ({\mathrm e}^{i x}+\frac {i a +b}{\sqrt {-a^{2}-b^{2}}}\right )}{\sqrt {-a^{2}-b^{2}}\, b}+\frac {\ln \left ({\mathrm e}^{i x}-1\right )}{b}-\frac {\ln \left ({\mathrm e}^{i x}+1\right )}{b}\) \(122\)

[In]

int(cot(x)/(b*cos(x)+a*sin(x)),x,method=_RETURNVERBOSE)

[Out]

1/b*ln(tan(1/2*x))+2*a/b/(a^2+b^2)^(1/2)*arctanh(1/2*(-2*b*tan(1/2*x)+2*a)/(a^2+b^2)^(1/2))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 142 vs. \(2 (44) = 88\).

Time = 0.29 (sec) , antiderivative size = 142, normalized size of antiderivative = 2.96 \[ \int \frac {\cot (x)}{b \cos (x)+a \sin (x)} \, dx=\frac {\sqrt {a^{2} + b^{2}} a \log \left (\frac {2 \, a b \cos \left (x\right ) \sin \left (x\right ) - {\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - a^{2} - 2 \, b^{2} - 2 \, \sqrt {a^{2} + b^{2}} {\left (a \cos \left (x\right ) - b \sin \left (x\right )\right )}}{2 \, a b \cos \left (x\right ) \sin \left (x\right ) - {\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + a^{2}}\right ) - {\left (a^{2} + b^{2}\right )} \log \left (\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right ) + {\left (a^{2} + b^{2}\right )} \log \left (-\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right )}{2 \, {\left (a^{2} b + b^{3}\right )}} \]

[In]

integrate(cot(x)/(b*cos(x)+a*sin(x)),x, algorithm="fricas")

[Out]

1/2*(sqrt(a^2 + b^2)*a*log((2*a*b*cos(x)*sin(x) - (a^2 - b^2)*cos(x)^2 - a^2 - 2*b^2 - 2*sqrt(a^2 + b^2)*(a*co
s(x) - b*sin(x)))/(2*a*b*cos(x)*sin(x) - (a^2 - b^2)*cos(x)^2 + a^2)) - (a^2 + b^2)*log(1/2*cos(x) + 1/2) + (a
^2 + b^2)*log(-1/2*cos(x) + 1/2))/(a^2*b + b^3)

Sympy [F]

\[ \int \frac {\cot (x)}{b \cos (x)+a \sin (x)} \, dx=\int \frac {\cot {\left (x \right )}}{a \sin {\left (x \right )} + b \cos {\left (x \right )}}\, dx \]

[In]

integrate(cot(x)/(b*cos(x)+a*sin(x)),x)

[Out]

Integral(cot(x)/(a*sin(x) + b*cos(x)), x)

Maxima [A] (verification not implemented)

none

Time = 0.30 (sec) , antiderivative size = 79, normalized size of antiderivative = 1.65 \[ \int \frac {\cot (x)}{b \cos (x)+a \sin (x)} \, dx=\frac {a \log \left (\frac {a - \frac {b \sin \left (x\right )}{\cos \left (x\right ) + 1} + \sqrt {a^{2} + b^{2}}}{a - \frac {b \sin \left (x\right )}{\cos \left (x\right ) + 1} - \sqrt {a^{2} + b^{2}}}\right )}{\sqrt {a^{2} + b^{2}} b} + \frac {\log \left (\frac {\sin \left (x\right )}{\cos \left (x\right ) + 1}\right )}{b} \]

[In]

integrate(cot(x)/(b*cos(x)+a*sin(x)),x, algorithm="maxima")

[Out]

a*log((a - b*sin(x)/(cos(x) + 1) + sqrt(a^2 + b^2))/(a - b*sin(x)/(cos(x) + 1) - sqrt(a^2 + b^2)))/(sqrt(a^2 +
 b^2)*b) + log(sin(x)/(cos(x) + 1))/b

Giac [A] (verification not implemented)

none

Time = 0.31 (sec) , antiderivative size = 75, normalized size of antiderivative = 1.56 \[ \int \frac {\cot (x)}{b \cos (x)+a \sin (x)} \, dx=\frac {a \log \left (\frac {{\left | 2 \, b \tan \left (\frac {1}{2} \, x\right ) - 2 \, a - 2 \, \sqrt {a^{2} + b^{2}} \right |}}{{\left | 2 \, b \tan \left (\frac {1}{2} \, x\right ) - 2 \, a + 2 \, \sqrt {a^{2} + b^{2}} \right |}}\right )}{\sqrt {a^{2} + b^{2}} b} + \frac {\log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) \right |}\right )}{b} \]

[In]

integrate(cot(x)/(b*cos(x)+a*sin(x)),x, algorithm="giac")

[Out]

a*log(abs(2*b*tan(1/2*x) - 2*a - 2*sqrt(a^2 + b^2))/abs(2*b*tan(1/2*x) - 2*a + 2*sqrt(a^2 + b^2)))/(sqrt(a^2 +
 b^2)*b) + log(abs(tan(1/2*x)))/b

Mupad [B] (verification not implemented)

Time = 23.21 (sec) , antiderivative size = 123, normalized size of antiderivative = 2.56 \[ \int \frac {\cot (x)}{b \cos (x)+a \sin (x)} \, dx=\frac {\ln \left (\frac {\sin \left (\frac {x}{2}\right )}{\cos \left (\frac {x}{2}\right )}\right )}{b}-\frac {2\,a\,\mathrm {atanh}\left (\frac {\sqrt {a^2+b^2}\,\left (4{}\mathrm {i}\,\sin \left (\frac {x}{2}\right )\,a^2+2{}\mathrm {i}\,\cos \left (\frac {x}{2}\right )\,a\,b+1{}\mathrm {i}\,\sin \left (\frac {x}{2}\right )\,b^2\right )}{a^3\,\sin \left (\frac {x}{2}\right )\,4{}\mathrm {i}+a^2\,b\,\cos \left (\frac {x}{2}\right )\,1{}\mathrm {i}+a\,b^2\,\sin \left (\frac {x}{2}\right )\,3{}\mathrm {i}+b\,\cos \left (\frac {x}{2}\right )\,\left (a^2+b^2\right )\,1{}\mathrm {i}}\right )}{b\,\sqrt {a^2+b^2}} \]

[In]

int(cot(x)/(b*cos(x) + a*sin(x)),x)

[Out]

log(sin(x/2)/cos(x/2))/b - (2*a*atanh(((a^2 + b^2)^(1/2)*(a^2*sin(x/2)*4i + b^2*sin(x/2)*1i + a*b*cos(x/2)*2i)
)/(a^3*sin(x/2)*4i + a^2*b*cos(x/2)*1i + a*b^2*sin(x/2)*3i + b*cos(x/2)*(a^2 + b^2)*1i)))/(b*(a^2 + b^2)^(1/2)
)